package com.jyw.business.de.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import com.jyw.business.de.domain.dto.web.DemandAnalyzeAddDto;
import com.jyw.business.de.domain.dto.web.DemandAuditPassDto;
import com.jyw.business.de.domain.dto.web.DemandOperDto;
import com.jyw.business.de.domain.dto.web.DemandProjectAuditPageDto;
import com.jyw.business.de.domain.vo.web.DemandProjectAuditPageVO;
import com.jyw.common.core.domain.CommonResult;
import com.jyw.common.core.page.BasePage;
import com.jyw.common.utils.DateUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jyw.common.annotation.Log;
import com.jyw.common.core.controller.BaseController;
import com.jyw.common.core.domain.AjaxResult;
import com.jyw.common.enums.BusinessType;
import com.jyw.business.de.domain.DeDemandProjectAudit;
import com.jyw.business.de.service.IDeDemandProjectAuditService;
import com.jyw.common.utils.poi.ExcelUtil;
import com.jyw.common.core.page.TableDataInfo;

/**
 * 需求-需求立项审核Controller
 * 
 * @author ruoyi
 * @date 2024-02-19
 */
@RestController
@RequestMapping("/de/demand/audit")
@Api(tags = "需求立项审核")
public class DeDemandProjectAuditController extends BaseController
{
    @Autowired
    private IDeDemandProjectAuditService deDemandProjectAuditService;

    /**
     * 查询需求-需求立项审核列表
     */
    @PostMapping("/list")
    public TableDataInfo<DemandProjectAuditPageVO> auditPage(@RequestBody DemandProjectAuditPageDto dto, BasePage page)
    {
        startPage();
        dto.setAuditEndTime(DateUtils.toEndDate(dto.getAuditEndTime()));
        dto.setCreateEndTime(DateUtils.toEndDate(dto.getCreateEndTime()));
        List<DemandProjectAuditPageVO> list = deDemandProjectAuditService.auditPage(dto);
        return getDataTable(list);
    }

    @PutMapping("/pass")
    @ApiOperation("通过审核")
    public CommonResult pass(@RequestBody @Valid DemandAuditPassDto dto)
    {
        deDemandProjectAuditService.pass(dto);
        return CommonResult.success();
    }

    @PutMapping("/reject")
    @ApiOperation("审核驳回")
    public CommonResult reject(@RequestBody @Valid DemandOperDto dto)
    {
        deDemandProjectAuditService.reject(dto);
        return CommonResult.success();
    }

}
